package test;

import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ThreadCopy implements ActionListener{
	private TrayIcon trayIcon;
	private String key;
	public ThreadCopy(TrayIcon trayIcon, String key) {
		super();
		this.trayIcon = trayIcon;
		this.key = key;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		StringSelection stringSelection = new StringSelection (this.key);
		Clipboard clpbrd = Toolkit.getDefaultToolkit ().getSystemClipboard ();
		clpbrd.setContents (stringSelection, null);
		this.trayIcon.displayMessage("Nhan Chatter", "Copied to paste", TrayIcon.MessageType.INFO);
		
	}
	
}
